package com.hdu.hot100.tanxin;

public class lc45 {
    class Solution {
        public int jump(int[] nums) {
            int ans = 0;
            int cur = 0;
            int next = 0;

            for (int i = 0; i < nums.length - 1; i++) {
                if (cur >= nums.length - 1) {
                    return ans;
                }
                next = Math.max(nums[i] + i, next);
                if (i == cur) {
                    ans++;
                    cur = next;
                }
            }

            return ans;
        }
    }
}
